package com.onejson.ojmall.controller;


import com.onejson.ojmall.common.domain.PageResult;
import com.onejson.ojmall.common.apiencrypt.domain.ValidateList;
import com.onejson.ojmall.common.domain.ResponseDTO;
import com.onejson.ojmall.model.form.SLoginLogBatchForm;
import com.onejson.ojmall.model.form.SLoginLogForm;
import com.onejson.ojmall.model.form.SLoginLogQueryForm;
import com.onejson.ojmall.model.vo.SLoginLogVO;
import com.onejson.ojmall.service.SLoginLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 用户登录日志控制器
 *
 * @author wxx
 */
@Slf4j
@RestController
@Tag(name = "用户登录日志")
public class SLoginLogController {


    //【用户登录日志】Service层

    @Resource
    private SLoginLogService sLoginLogService;


    @Operation(summary = "【用户登录日志】 - 查询")
    @PostMapping("/zichan/sLoginLog/queryPage")
    public ResponseDTO<PageResult<SLoginLogVO>> querySLoginLog(@RequestBody @Valid SLoginLogQueryForm queryForm) {
        return ResponseDTO.ok(sLoginLogService.getList(queryForm));
    }

    @Operation(summary = " 【用户登录日志】 - 详情")
    @GetMapping("/zichan/sLoginLog//{detailId}")
    public ResponseDTO<SLoginLogVO> getInfo(@PathVariable("detailId") String detailId) {
        return ResponseDTO.ok(sLoginLogService.queryById(detailId));
    }

    @Operation(summary = " 【用户登录日志】 - 添加")
    @PostMapping("/zichan/sLoginLog/add")
    public ResponseDTO<String> addSLoginLog(@RequestBody @Valid SLoginLogForm addForm) {
        return sLoginLogService.addSLoginLog(addForm);
    }

    @Operation(summary = "【用户登录日志】 - 更新")
    @PostMapping("/zichan/sLoginLog/update")
    public ResponseDTO<String> updateSLoginLog(@RequestBody @Valid SLoginLogForm updateForm) {
        return sLoginLogService.updateSLoginLog(updateForm);
    }

    @Operation(summary = "【用户登录日志】 - 批量更新")
    @PostMapping("/zichan/sLoginLog/batchUpdate")
    public ResponseDTO<String> batchUpdateSLoginLog(@RequestBody @Valid SLoginLogBatchForm sLoginLogBatchForm) {
        return sLoginLogService.batchUpdateSLoginLog(sLoginLogBatchForm);
    }

    @Operation(summary = "【用户登录日志】 - 批量删除")
    @PostMapping("/zichan/sLoginLog/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<String> idList) {
        return sLoginLogService.batchDelete(idList);
    }

    @Operation(summary = "【用户登录日志】 - 单个删除")
    @GetMapping("/zichan/SLoginLog/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable String id) {
        return sLoginLogService.delete(id);
    }

}

